#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const int N = 3e6 + 10;
int arr[N];
int cnt[N];
int n;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		scanf("%d", &n);
		for (int i = 0; i <= 2 * n; i++) {
			cnt[i] = 0;
		}
		int x;
		for (int i = 1; i <= n; i++) {
			scanf("%d", &arr[i]);
			arr[i] ^= arr[i - 1];
		}
		cnt[0] = 1;
		LL ans = (LL)n * (n + 1) / 2;
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j * j <= n * 2; j++) {
				int k = j * j;
				ans -= cnt[k ^ arr[i]];
			}
			cnt[arr[i]]++;
		}
		cout << ans << endl;
	}
	return 0;
}